{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Calculating Material Properties\n",
    "\n",
    "Using the calculator from [calorine](https://gitlab.com/materials-modeling/calorine)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from wizard.calculator import MaterialCalculator\n",
    "from wizard.atoms import SymbolInfo\n",
    "from calorine.calculators import CPUNEP\n",
    "\n",
    "symbol_info = SymbolInfo('W', 'bcc', 3)\n",
    "atoms = symbol_info.create_bulk_atoms()\n",
    "calc = CPUNEP('../Repository/UNEP_v1/potentials/4-4-80/nep.txt')\n",
    "material_calculator = MaterialCalculator(atoms, calc, symbol_info)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Calculate the lattice constants of the material, write them along with the atom energy to a file, and return the atom energy and cell lengths."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "material_calculator.lattice_constant()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Calculate the elastic constants of the material, write them to a file, and return the bulk modulus."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "material_calculator.elastic_constant()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Generate the equation of state (EOS) curve for the material, save the curve as a PNG image, and write the volume and energy data to a file."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "material_calculator.eos_curve()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Calculate and plot the phonon dispersion band structure for the material."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "material_calculator.phonon_dispersion()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Calculate the formation energy of a vacancy in the material, write it to a file, and return the formation energy."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "material_calculator.formation_energy_vacancy()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Calculate the migration energy of a vacancy in the material by simulating the transition from the initial to the final state."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "material_calculator.migration_energy_vacancy()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Calculate the formation energy of divacancies in the material, write it to a file, and return the formation energy."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "nth = 1\n",
    "material_calculator.formation_energy_divacancies(nth)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Calculate the formation energy of a self-interstitial atom (SIA) in the material, write it to a file, and return the formation energy."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vector = (1,1,1)\n",
    "material_calculator.formation_energy_sia(vector)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Calculate the formation energy of an interstitial atom in the material, write it to a file, and return the formation energy."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "material_calculator.formation_energy_interstitial_atom('W',[0,0,1/2],'octahedral')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Calculate the formation energy of a surface in the material, write it to a file, and return the formation energy in meV."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "miller = (0, 0, 1)\n",
    "material_calculator.formation_energy_surface(miller)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Calculate the energy of a stacking fault in the material by simulating the shift of atomic layers, write the maximum energy to a file, plot the energy as a function of shift distance, and return the energy values."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "material_calculator.stacking_fault(a = (1,1,-1), b = (1,-1,0), miller = [1,1,2], distance = 3.185/2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Simulate the movement of a screw dislocation dipole in a pure BCC metal, calculate the energy at each step, save the energy profile as a PNG image, and return the energy values."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "material_calculator.bcc_metal_screw_dipole_move()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Simulate the movement of a single screw dislocation in a pure BCC metal, calculate the energy at each step, save the energy profile as a PNG image, and return the energy values."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "material_calculator.bcc_metal_screw_one_move()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
